#!/usr/bin/env bash
#############################
download_old_version_video_tutorial() {
	cd /sdcard/Download
	if [ -f "20200229vnc教程06.mp4" ]; then
		if (whiptail --title "检测到视频已下载,请选择您需要执行的操作！" --yes-button 'Play播放o(*￣▽￣*)o' --no-button '重新下载(っ °Д °)' --yesno "Detected that the video has been downloaded, do you want to play it, or download it again?" 7 60); then
			play_video_tutorial
		else
			download_old_version_video_tutorial
		fi
	else
		download_old_version_video_tutorial
	fi
}
##########################
download_old_version_video_tutorial() {
	if [ $(command -v aria2c) ]; then
		aria2c --console-log-level=warn --no-conf -x 6 -k 1M --split=6 --allow-overwrite=true -o "20200229vnc教程06.mp4" "https://m.tmoe.me/tmoe-vnc_video-tutorial_06"
	else
		curl -Lo "20200229vnc教程06.mp4" "https://m.tmoe.me/tmoe-vnc_video-tutorial_06"
	fi
	play_video_tutorial
}
#######################
play_video_tutorial() {
	termux-open "20200229vnc教程06.mp4"
	printf "%s\n" "${YELLOW}若视频无法自动播放，则请进入下载目录手动播放。${RESET}"
	printf "%s\n" "If the video does not play automatically, please enter the download directory to play it manually."
	printf "%s\n" "按回车键继续,按Ctrl+C取消。"
	printf "%s\n" "${YELLOW}Press enter to continue.${RESET}"
	read
	am start -n com.android.documentsui/com.android.documentsui.ViewDownloadsActivity
	cd ${CURRENT_DIR}
}
#######################################
download_old_version_video_tutorial $@
